package cn.sciento.starter.social.wechat.connection;

import cn.sciento.starter.social.core.common.api.SocialApi;
import cn.sciento.starter.social.core.common.connect.SocialApiAdapter;
import cn.sciento.starter.social.wechat.api.WechatUser;
import org.springframework.social.connect.ConnectionValues;

public class WechatApiAdapter extends SocialApiAdapter {
  public WechatApiAdapter() {}
  
  public WechatApiAdapter(String providerUserId) {
    super(providerUserId);
  }
  
  public void setConnectionValues(SocialApi api, ConnectionValues values) {
    WechatUser user = (WechatUser)api.getUser(getProviderUserId());
    values.setDisplayName(user.getNickname());
    values.setImageUrl(user.getHeadimgurl());
    values.setProviderUserId(user.getOpenid());
    values.setProviderUnionId(user.getUnionid());
  }
}
